import os
import json
from conf.settings import STUDENT2COURSE_JSON_PATH
from loguru import logger

def loads_students2course_json():
    student2course = {

    }
    if os.path.exists(STUDENT2COURSE_JSON_PATH):
        with open(STUDENT2COURSE_JSON_PATH, "r", encoding="utf-8") as f:
            student2course = json.load(f)
        logger.info(f"{STUDENT2COURSE_JSON_PATH}加载成功！")
    return student2course

def save_students2course(students2course):
    with open(STUDENT2COURSE_JSON_PATH, "w", encoding="utf-8") as f:
        # json.dumps()
        json.dump(students2course, f)